import 'package:flutter/material.dart';
// import 'package:flutter/widgets.dart';
import 'HomeBody.dart';
import '../cinema/CinemaList.dart';
import '../movie/MovieList.dart';

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // 脚手架工具
    // tab导航的控制器
    return DefaultTabController(
      // 导航控制页面切换的数量
      length: 3,
      child: Scaffold(
        // 顶部导航
        appBar: AppBar(
          title: Text('私人影院'),
          centerTitle: true, // 居中
          // 导航栏按钮
          actions: <Widget>[
            IconButton(
              icon: Icon(Icons.search),
              onPressed: (){},
            )
          ],
        ),
        // drawer 侧边栏
        drawer: Drawer(
          // 从上到下排列的合资容器   也能从左往右拍
          child: ListView(
            // 去掉顶部的padding
            padding: EdgeInsets.all(0),
            children: <Widget>[
              UserAccountsDrawerHeader(
                accountName: Text('范禀坤'),
                accountEmail: Text('811757912@qq.com'),
                // 头像
                currentAccountPicture: CircleAvatar(
                  backgroundImage: NetworkImage('https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2188118499,572678618&fm=26&gp=0.jpg'),
                ),
                // 装饰器
                decoration: BoxDecoration(
                  image: DecorationImage(
                    fit: BoxFit.cover,
                    image: NetworkImage('http://gss0.baidu.com/7Po3dSag_xI4khGko9WTAnF6hhy/zhidao/pic/item/b3b7d0a20cf431addc902f154936acaf2edd985f.jpg')
                  )
                ),
              ),
              ListTile(
                title: Text('我的发布'),
                trailing: Icon(Icons.send),
              ),
              ListTile(
                title: Text('我的收藏'),
                trailing: Icon(Icons.feedback),
              ),
              ListTile(
                title: Text('系统设置'),
                trailing: Icon(Icons.settings),
              ),
              Divider(color: Colors.black45),
              ListTile(
                title: Text('注销'),
                trailing: Icon(Icons.exit_to_app),
              ),
            ],
          ),
        ),
        // 页面需要传递  TabBarView  来实现联动效果
        body: TabBarView(
          children: <Widget>[
            HomeBody(),
            MovieList(),
            // Detail(),
            CinemaList()
          ],
        ),
        // 底部导航
        bottomNavigationBar: Container(
          height: 50,
          decoration: BoxDecoration(
            color: Colors.black
          ),
          child: TabBar(
            labelStyle: TextStyle(
              height: 0,
              fontSize: 11
            ),
            tabs: <Widget>[
              Tab( text: '首页', icon: Icon(Icons.home)),
              Tab( text: '正在热映', icon: Icon(Icons.movie_filter)),
              Tab( text: '影院信息', icon: Icon(Icons.movie_creation)),
            ],
          ),
        )
      ),
    );
  }
}